class Pagination { public $total = 0; public $page = 1; public $limit = 20; public $num_links = 8; public $url = ''; public $text_first = '|<'; public $text_last = '>|'; public $text_next = '>'; public $text_prev = '<'; public function prevnext() { $total = is_numeric($this->total) ? (int)$this->total : 0; $page = is_numeric($this->page) ? (int)$this->page : 1; $limit = is_numeric($this->limit) && $this->limit > 0 ? (int)$this->limit : 10; $num_pages = ceil($total / $limit); $output = array(); if ($page > 1) { $output[] = array("rel" => "prev", "href" => str_replace('{page}', $page - 1, $this->url)); } if ($page < $num_pages) { $output[] = array("rel" => "next", "href" => str_replace('{page}', $page + 1, $this->url)); } return $output; } public function render() { $total = is_numeric($this->total) ? (int)$this->total : 0; $page = is_numeric($this->page) ? (int)$this->page : 1; $limit = is_numeric($this->limit) && $this->limit > 0 ? (int)$this->limit : 10; $num_pages = ceil($total / $limit); if (empty($this->url)) { $this->url = '#'; // Default to prevent errors } $this->url = str_replace('%7Bpage%7D', '{page}', $this->url); $output = '